<template>
  <div style="background: #FFF;" >
    <headNav title="个人信息" :isBack="false" ></headNav>
    <div class="headBackground" @click="$router.push('setUp')" >
      <div class="informationDivCss" >
        <div class="flexCenter headCss" >
          <img src="@/assets/img/default_heads.png" mode="" v-if="!identityData.portraitImgUrl" >
          <img :src="identityData.portraitImgUrl" mode="" v-if="identityData.portraitImgUrl" >
        </div>
        <div class="flexHeight  nameDivCss" >
          <div class="flexAlign textImgCss" style="overflow: hidden;" >
            <span>{{identityData.name}}</span>
            <img src="@/assets/img/my/vip.png" mode="" v-if=" roleCode != 'Teacher' && identityData.isVip" >
            <img src="@/assets/img/my/fvip.png" mode="" v-if=" roleCode != 'Teacher' && !identityData.isVip" >
						<img src="@/assets/img/my/guard.png" mode="" v-if=" roleCode == 'Teacher' && identityData.isBenefitUser" style="width: 2.2rem; height: 0.4rem;" >
          </div>
          <div style="width: 4rem; height: 30%;" >
            {{identityData.loginName}}
          </div>
        </div>
        <div class="flexCenter arrowCss" >
          <img src="@/assets/img/my/arrow.png" mode="" >
        </div>
      </div>
    </div>

    <!-- 教师身份组件 -->
    <teacherstatus v-if="roleCode == 'Teacher'" ></teacherstatus>
    <!-- 学生身份组件 -->
    <parenthood v-else ></parenthood>
    <bottomNav :index="4" ></bottomNav>
  </div>
</template>

<script>
import headNav from '@/components/headNav/headNav.vue'
import { mapActions, mapState, mapGetters, mapMutations } from 'vuex'
import parenthood from './components/parenthood.vue'
import teacherstatus from './components/teacherStatus.vue'
import { parentDirectoryApi, teacherDirectoryApi } from '@/api/myNewApi'
import bottomNav from '@/components/bottomNav/bottomNav'
export default {
  components: {
    headNav,
    parenthood,
    teacherstatus,
    bottomNav
  },
  computed: {
    ...mapState({
      studentId: state => state.user.studentId,
      roleCode: state => state.user.roleCode
    }),
    identityData () {
        return this.$store.state.myInfo.identityData
    }
  },
  data () {
    return {
    
    }
  },
  methods: {

  },
  async mounted() {
    var res = ''
    if (this.roleCode == 'Teacher') {
      res = await teacherDirectoryApi()
    } else {
      res = await parentDirectoryApi()
    }
    this.$store.commit('myInfo/setIdentityData', res)

  }
}
</script>

<style lang="less" scoped>
 .arrowCss {
   width: 0.6rem;
   height: 100%;
   font-size: 0.3rem;
   img {
     width: 0.13rem;
     height: 0.2rem;
   }
 }

 .nameDivCss {
   width: 4rem;
   height: 100%;
   margin-bottom: 0.2rem;
 }

 .textImgCss {
   width: 4rem;
   height: 25%;
   font-size: 0.32rem;
   font-weight: 600;
   margin: 0.4rem 0 0.1rem 0;
  //  overflow-x: hidden;
   img {
     width: 0.94rem;
     height: 0.32rem;
     margin: 0.04rem 0 0 0.1rem;
   }
 }

 .headCss {
   width: 1.8rem;
   height: 100%;
   img {
     width: 1.2rem;
     height: 1.2rem;
     border-radius: 2.5rem;
   }
 }

.informationDivCss {
  width: 6.6rem;
  height: 1.8rem;
  background: #FFF;
  border-radius: 0.15rem;
  margin-left: 0.3rem;
  display: flex;
  border: 2px solid #F7F1F1;
}

.headBackground {
  width: 7.2rem;
  height: 1.3rem;
  background-image: url('../../assets/img/bo.png');
  background-size:100% 100%;
  margin-bottom: 0.8rem;
}

.flexCenter {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flexHeight {
  display: flex;
  flex-direction: column;
}

.flexAlign {
  display: flex;
  align-items: center;
}
</style>
